package com.itheima.pinda.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.itheima.pinda.common.CustomIdGenerator;
import com.itheima.pinda.entity.Member;
import com.itheima.pinda.mapper.PdMemberMapper;
import com.itheima.pinda.service.PdMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 用户服务类实现
 */
@Service
public class PdMemberServiceImpl implements PdMemberService {

    @Autowired
    private CustomIdGenerator idGenerator;
    @Autowired
    private PdMemberMapper memberMapper;

    @Override
    @Transactional
    public Member insert(Member member) {

        member.setId(idGenerator.nextId(member) + "");
        memberMapper.insert(member);
        return member;
    }

    @Override
    public Member selectById(String id) {
        return memberMapper.selectById(id);
    }

    @Override
    public IPage selectByPage(Integer pageNum, Integer pageSize) {

        return null;
    }

    @Override
    public void delete(List<String> ids) {
        memberMapper.delete(new LambdaQueryWrapper<Member>().in(Member::getId,ids));
    }
}